/******************************************************************************
ISYS 1078 / 1079 — Information Retrieval
Assignment #1

Student Name: [ Rui, Wang ]
Student ID: [ 3171459 ]
CSIT username: [ rwang ]
*******************************************************************************/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include "func.h"

/*Index app
  Used for creating term Lexicon, inverted lists and document Map files, which are used for
  search app
*/

int main(int argc, char **argv)
{
  int mode;
  DocIndex docIndex;
  LexIndex lexIndex;
  
clock_t start, end;

  if(argc < 2|| argc > 3)
  {
    fprintf(stderr, "Usage: %s [-p] <sourcefile>\n",argv[0]);
    return -1; 
  }

  if( strcmp(argv[1],"-p") == 0 || strcmp(argv[1],"-P") == 0 )
      mode = 0;
  else
	  mode = 1;
	
  start = clock();

  DocIndexInit(&docIndex);
  LexIndexInit(&lexIndex);
  DataParse(mode, argv[argc-1], &docIndex, &lexIndex);
  DestroyTask(&docIndex, &lexIndex);

  end = clock();

  fprintf(stderr,"\nIndexing time is: %f seconds\n\n",(double)(end-start)/CLOCKS_PER_SEC);
 
   return 0;
}

